//
//  T4_3_CCell.swift
//  Pods
//
//  Created by eme on 2017/4/10.
//
//

/*
 owner:cy
 update:2017年04月10日18:20:10
 info: 商品类 cell
 VC :  HomePageVc
 */
import UIKit
import RxSwift
import UtilCore
import RickonCore
import BrandonCore

class T4_3_CCell: UICollectionViewCell {
    
    static let interitemSpacing:CGFloat = 5
    static let lineSpacing:CGFloat = 5
    static let cellTop:CGFloat = 5
    static let cellBottom:CGFloat = 5
    static let cellLeft:CGFloat = 5
    static let cellRight:CGFloat = 5
    static var cellSize:CGSize{
        get{
            let width:CGFloat = (screen_Width - T4_3_CCell.lineSpacing - T4_3_CCell.cellLeft - T4_3_CCell.cellRight)/2
            if Device.size == .Screen4Inch {
                let height:CGFloat = width * 529/360
                return CGSize(width: width, height: height)
            }else{
                let height:CGFloat = width * 509/360
                return CGSize(width: width, height: height)
            }
            
        }
    }
    static var cellEdgeInsets:UIEdgeInsets{
        get{
            return  UIEdgeInsets(top: T4_3_CCell.cellTop, left: T4_3_CCell.cellLeft, bottom: T4_3_CCell.cellBottom, right: T4_3_CCell.cellRight)
        }
    }
    
    @IBOutlet weak var sprepeat_bg_Line_V: UIView!
    //商品名称
    @IBOutlet weak var pddes_Lb: UILabel!
    //商品名称
    @IBOutlet weak var pdname_Lb: UILabel!
    //店铺进货价
    @IBOutlet weak var shprice_Lb: UILabel!
    
    @IBOutlet weak var jinPriceImg_V: UIImageView!
    //品牌名称
    @IBOutlet weak var brname_Lb: UILabel!
    
    @IBOutlet weak var img1_ImgV: UIImageView!
    
    /// 显示已售罄
    @IBOutlet weak var sellOut_ImgV: UIImageView!
    var item :T4ListModel?{
        didSet{
            if let item = self.item {
                self.pddes_Lb.text = item.pddes
                self.pdname_Lb.text = item.pdname
                self.brname_Lb.text = item.brname
                self.img1_ImgV.setUrlImage(item.img1)
                self.jinPriceImg_V.image = UIImage(named: AppData.getPriceImgName(), in: RobbCore.bundle, compatibleWith: nil)
                self.shprice_Lb.text = AppData.getFinalShowPrice(jinPrice: item.minagprice, lingPrice: item.bdprice).getPriceStr()
                if item.stock == 0 || item.pdstate != "3" {
                    self.sellOut_ImgV.isHidden = false
                    self.sellOut_ImgV.image = UIImage(named: item.stock == 0 ?"sellout":"failure", in: RobbCore.bundle, compatibleWith: nil)
                }else{
                    self.sellOut_ImgV.isHidden = true
                }
            }
        }
    }
    override func awakeFromNib() {
        self.sprepeat_bg_Line_V.backgroundColor = Theme.robb.homePage.homepage_bg
        self.pddes_Lb.bold_fontSize(13)
        self.pdname_Lb.normal_fontSize(13)
        self.brname_Lb.normal_fontSize(12)
        self.shprice_Lb.bold_fontSize(14)
    }
    
}
